function getList(pageconf) {
				if(!pageconf){
					pageconf={};
					pageconf.pageSize=6;
					pageconf.currentPage=1;
				}
				$.ajax({
					type: "get",
					url: ip + getUrl,
					data: {
						"page":pageconf.currentPage,
						"size":pageconf.pageSize,
					},
					dataType: "json",
					xhrFields: {
						withCredentials: true
					},
					crossDomain: true,
					success: function(res) {
						console.log(res.data);
						//填充
						//setTable(res.data.content);
						if(res.data){
							total=res.data.total;
							getPage(pageconf,res.data.datas)
							if(typeof res.data=="string"){
								
								$("#form").addClass("hidden")
								$("#note").removeClass("hidden")
								$("#layui").addClass("hidden")
							}else{
								
							}
						}
					},
					async: true
				});
			}
			
			
			function getPage(pageconf,date){
				layui.use(['laypage','layer'],function(){
					var laypage=layui.laypage;
						
					laypage.render({
						elem:'layui',
						count:total,
						skin:'#7c62ad',
						curr:pageconf.currentPage,
						limit:pageconf.pageSize,
						limits:[6,12,18,24],
						skip:true,
						first:"首页",
						last:"尾页",
						layout:['count','skip', 'next', 'prev'],
						jump:function(obj,first){
							page=obj.curr;
							limit=obj.limit;
							if(!first){
								 pageconf.currentPage=obj.curr;
								 pageconf.pageSize=obj.limit;
								 getList(pageconf);
							}
						}
						 
						
					});
					fillTable(date,(pageconf.currentPage-1)*pageconf.pageSize);
					
				});
			}
			
			function fillTable(date,num){
				var info='';
				$.each(date, function(index,obj) {
					index=index+num+1;
					if(obj.used==true){
					info += "<tr class='column'><td>" + index + "</td><td class='column'>" + obj.name + "</td><td class='column'>" +"<button  class='btn btn-effect-ripple btn-info ml-2' id='btn-detail' name='" + obj.id + "' onclick='checkDetail(this.name)'>详情</button><a href='#modal-chgTitle'  class='btn btn-effect-ripple btn-primary ml-2 ' id='btn-edit' name='" + obj.id +"' onclick='getId(this.name)' data-toggle='modal'>编辑</a><button class='btn btn-effect-ripple btn-primary ml-2' id='btn-create' name='"+obj.id +"' onclick='createSurvey(this.name)'>新建调查</button><a class='btn btn-effect-ripple btn-danger ml-2  '  disabled>删除</a><a class='btn btn-effect-ripple btn-warning ml-2 hidden' disabled>更新</a>"+ "</td>" 
					
					}else{
					info += "<tr class='column'><td>" + index + "</td><td class='column'>" + obj.name + "</td><td>" +"<button class='btn btn-effect-ripple btn-info ml-2' id='btn-detail' name='" + obj.id + "' onclick='checkDetail(this.name)'>详情</button><a href='#modal-chgTitle' class='btn btn-effect-ripple btn-primary ml-2' id='btn-edit' name='" + obj.id +"' onclick='getId(this.name)'  data-toggle='modal'>编辑</a><button class='btn btn-effect-ripple btn-primary ml-2' id='btn-create' name='"+obj.id +"' onclick='createSurvey(this.name)'>新建调查</button><a href='#modal-delete' class='btn btn-effect-ripple btn-danger ml-2' onclick='trasnId(this.name)' name='" + obj.id + "' data-toggle='modal'>删除</a><a href='#modal-update' class='btn btn-effect-ripple btn-warning ml-2 hidden' data-toggle='modal'>更新</a>"+ "</td>" 	
					}
					});
				$("#tab_list").html(info);
			}


var page=1; //设置首页页码
var size=25;
var searchKeyWords="";
var ip="http://10.21.30.218:8000";
 //按钮单个禁用
 $(document).on('click', '.forbidden', function() {
                k = $(this).parents("tr").index() + 1;
                var element = this;
                var userid=this.id;
                console.log(userid);
                layui.use('layer', function() {
                    var layer = layui.layer;
                    layer.confirm('是否要禁用该人', {
                        icon: 2,
                        title: '提示'
                    }, function(index) {
                        layer.confirm('禁用后不可恢复 是否仍禁用？', {
                            icon: 2,
                            title: '提示'
                        }, function(index) {
                        $.ajax({
                            type: "PUT",
                            url: "http://10.21.30.218:8000/questionnaire/user/offUser?userId="+userid,
                            data: {
                             	
                             },
                            async: true,
                            dataType: "json",
                            contentType: "application/json",
                            success: function(data) {
                         		$("table#teacherInfo").find("tr:eq(" + k + ")").children('td:nth-child(6)').children('.forbidden').attr('class', 'layui-btn layui-btn-disabled  layui-btn-small')
                             	layer.close(index);
                             },
                          	Error: function() {
                                 alert("服务器出错");
                            }
                         })
                        })
                    });

                });
            })



//创建教师列表
function createTeacherList(){
	$("#peoplelist").append(
					'<div id=list1>' +

					'<table id="teacherInfo"class="display" cellspacing="0" width="100%">\n' +
					'        <thead>\n' +
					'        <tr>\n' +
					'            <th width="5%"><input id="checkAll" class="checkAll" type="checkbox" value=""></th>\n' +
					'            <th width="15%" id="th_worknumber" >工号</th>\n' +
					'            <th width="10%" id="th_tname" >姓名</th>\n' +
					'            <th width="25%" id="th_department">部门</th>\n' +
					'            <th width="15%" id="th_telenumber" >手机</th>\n' +
					'            <th width="30%" id="th_action" >操作</th>\n' +

					'        </tr>\n' +
					'        </thead>\n' +
					'        <tbody style="font-size: 14px">\n' +
					'        </tbody>\n' +
					'    </table>' +
					'</div>');
					 $('#teacherInfo').DataTable({
					 	'paging':false,
					 	searching:false,
					 	"columnDefs": [ 
							{ "orderable": false, "targets": 5}
						],
					 });

		

				
				
				
	
	
}
//教师列表填充数据
function teacherTableDataAjax(){
	$.ajax({
		type:"get",
		url:"http://10.21.30.218:8000/questionnaire/user?userTypeId=5b88e7e8dc8b5a1a84a96368&page="+page+"&size=25&keyWord="+searchKeyWords,
		data:{
			
		},
		async:true,
		dataType:"json",
		contentType:" application/json",
		xhrFields:{withCredentials:true},
		crossDomain:true,
		success:function(obj){
			console.log(obj)
			$('#teacherInfo').dataTable().fnClearTable(); //清除表格内
			expressdata(obj)
		},
		Error:function(){
			alert("服务器出错");
		}
		
	})
	
	
	
	
}

//填充教师列表的数据操作
function expressdata(obj){
	
	$.each(obj.data.data, function(index, item) {
		if(item.flag==true){
			$('#teacherInfo').dataTable().fnAddData([
				'<input type="checkbox" name="ordercheck" id="' + item.id+ '">',
				item.username,
				item.name,
				item.collegeName,
				item.longPhone,
				'<div class="layui-btn  layui-btn-small delete" id="' + item.id+ '"  >删除</div><div class="layui-btn  layui-btn-small forbidden" id="' + item.id+ '">禁用</div>'
			]);
		}
		if(item.flag==false){
			$('#teacherInfo').dataTable().fnAddData([
				'<input type="checkbox" name="ordercheck" id="' + item.id+ '">',
				item.username,
				item.name,
				item.collegeName,
				item.longPhone,
				'<div class="layui-btn  layui-btn-small delete" id="' + item.id+ '"  >删除</div><div class="layui-btn layui-btn-disabled layui-btn-small " id="' + item.id+ '">禁用</div>'
			]);
		}
		
	});

}
//创建学生列表
function createStudentList(){
	$("#peoplelist").append(

					'<div id=list2>' +

					'<table id="studentInfo" class="display" cellspacing="0" width="100%">\n' +
					'        <thead>\n' +
					'        <tr>\n' +
					'            <th width="2%"><input id="checkAll" class="checkAll" type="checkbox" value=""></th>\n' +
					'            <th width="10%" id="th_stuid" >学号</th>\n' +
					'            <th width="10%" id="th_stuname" >姓名</th>\n' +
					'            <th width="8%" id="th_stusex">性别</th>\n' +
					'            <th width="10%" id="th_grade" >年级</th>\n' +
					'            <th width="10%" id="th_academy" >学院</th>\n' +
					'            <th width="10%" id="th_major" >专业</th>\n' +
					'            <th width="10%" id="th_class" >班级</th>\n' +
					'            <th width="15%" id="th_stutele" >手机</th>\n' +
					'            <th width="15%" id="th_action" >操作</th>\n' +

					'        </tr>\n' +
					'        </thead>\n' +
					'        <tbody style="font-size: 14px">\n' +
					'        </tbody>\n' +
					'    </table>' +
					'</div>');

				$("#studentInfo").DataTable({
					'paging':false,
					searching:false,
					"columnDefs": [ 
							{ "orderable": false, "targets": 9}
						],
				});

	
	
	
}
//学生列表填充数据
function studentTableDataAjax(){
	$.ajax({
		type:"get",
		url:"http://10.21.30.218:8000/questionnaire/user?userTypeId=5b88e7a5dc8b5a1a84a96367&page="+page+"&size=25&keyWord="+searchKeyWords,
		data:{
			
		},
		async:true,
		dataType:"json",
		contentType:" application/json",
		xhrFields:{withCredentials:true},
		crossDomain:true,
		success:function(obj){
			console.log(obj)
			$('#studentInfo').dataTable().fnClearTable(); //清除表格内
			expressstudata(obj)
		},
		Error:function(){
			alert("服务器出错");
		}
	})
}


//给学生列表
function expressstudata(obj){
	$.each(obj.data.data, function(index, item) {
		if(item.flag==true){
			$('#studentInfo').dataTable().fnAddData([
				'<input type="checkbox" name="ordercheck">',
				item.username,
				item.name,
				item.gender,
				item.grade,
				item.collegeName,
				item.major,
				item.className,
				item.longPhone,
				'<div><div class="layui-btn  layui-btn-small delete"style="float:left;" id="' + item.id+ '"  >删除</div> <div class="layui-btn  layui-btn-small forbidden" style="float:right;" id="' + item.id+ '"  >禁用</div></div> '
			]);
		};
		if(item.flag==false){
			$('#studentInfo').dataTable().fnAddData([
				'<input type="checkbox" name="ordercheck">',
				item.username,
				item.name,
				item.gender,
				item.grade,
				item.collegeName,
				item.major,
				item.className,
				item.longPhone,
				'<div><div class="layui-btn  layui-btn-small delete" style="float:left;" id="' + item.id+ '"  >删除</div><div class="layui-btn layui-btn-disabled layui-btn-small " style="float:right;"id="' + item.id+ '"  >禁用</div></div> '
			]);
		};					
	});
}

//创建辅导员列表
function creatcounsellorList(){
	$("#peoplelist").append(
					'<div id=list3>' +

					'<table id="counsellorInfo" class="table table-striped table-bordered table-hover" width="100%">\n' +
					'        <thead>\n' +
					'        <tr>\n' +
					'            <th width="10%"><input id="checkAll" class="checkAll" type="checkbox" value=""></th>\n' +
					'            <th width="25%" id="coacademy" >工号</th>\n' +
					'            <th width="20%" id="coname" >姓名</th>\n' +

					'            <th width="25%" cotelenumber" >手机</th>\n' +
					'            <th width="25%" id="th_action" >操作</th>\n' +

					'        </tr>\n' +
					'        </thead>\n' +
					'        <tbody style="font-size: 14px">\n' +
					'        </tbody>\n' +
					'    </table>' +
					'</div>');

				$("#counsellorInfo").DataTable();
	
	
	
	
}

//分页操作
function getPage(){
    layui.use(['laypage', 'layer'], function(){
  	var laypage = layui.laypage
  	,layer = layui.layer;
 
            //执行一个laypage实例
            laypage.render({
                elem: 'demo2' //注意，这里的 test1 是 ID，不用加 # 号
                ,count: 5000, //数据总数，从服务端得到
                limit:25,   //每页条数设置
                jump: function(obj, first){
                    //obj包含了当前分页的所有参数，比如：
                    console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                    console.log(obj.limit); //得到每页显示的条数
                    page=obj.curr;  //改变当前页码
                    limit=obj.limit;
                    //首次不执行
                    if(!first){
                        teacherTableDataAjax()  //加载数据
                        studentTableDataAjax()
                    }
                }
            });
        });
    }

function getKeyword(){
	$('#search-form').autocomplete({
		width: 200,
		height: 25,
		onSubmit: function(text){
			searchKeyWords=text;
		    console.log(searchKeyWords);
		    page=1;
		    getPage();
		    teacherTableDataAjax();
		    studentTableDataAjax()
		}
	});
}
//删除按钮
			 $(document).on('click', '.delete', function() {
			 	
			 	var userId=this.id;
		 		layui.use('layer', function() {
		 			var layer = layui.layer;
		 			layer.confirm('是否要删除该人员', {
		 			btn: ['取消', '确定'],
		 			icon: 2,
		 			title: '提示',
		 			btn2:function(index, layero){
		 				$.ajax({
		 				type: "delete",
		 				url: ip + "/questionnaire/user/"+userId,
		 				data: {},
		 				async: true,
		 				dataType: "",
		 				contentType: "application/json",
		 				success: function(res) {
		 					/*window.location.reload();*/
		 					if(res.code==-1){
		 						layer.msg(res.msg);
		 					}
							layer.close(index);
						
		 				},
		 				Error: function() {
		 					alert("服务器出错");
		 				}
		 			})
		 				
		 		}
		 			
		 	})
		
		});
			 	
			 	
			 	
			 })

$(document).ready(function(){
	createTeacherList()
	teacherTableDataAjax()
	getPage()
	getKeyword()
	createStudentList()
	studentTableDataAjax()
	/*creatcounsellorList()*/
	
	$("#list1").hide();
	$("#list2").hide();
	$("#list3").hide();
	$("#peoplegroup").change(function() {
					if($(this).val() == "老师") {
						
						$("#list2").hide();
					    $("#list3").hide();
						$("#list1").show();

					}
					if($(this).val() == "学生") {
						
						$("#list1").hide();
						$("#list3").hide();
						$("#list2").show();
					}
					if($(this).val() == "辅导员") {
					
						$("#list1").hide();
						$("#list2").hide();
						$("#list3").show();
					}
				    

				});
				
	$('#checkAll').on('click', function () {
            if (this.checked) {
                $(this).attr('checked','checked')
                $("input[name='ordercheck']").each(function () {
                    this.checked = true;
                });
            } else {
                $(this).removeAttr('checked')
                $("input[name='ordercheck']").each(function () {
                    this.checked = false;
                });
            }
        });
			
})
	
layui.use('upload', function() {
				var upload = layui.upload;
				var uploadInst = upload.render({
					elem: '#test1' ,
					url:'http://10.21.30.218:8000/questionnaire/user/addUsers',
					accept: 'file',
					data: {
  						userTypeId: function(){
    						if($("#peoplegroup").val()=="老师")
    						{
    							return "5b88e7e8dc8b5a1a84a96368";
    						};
    						if($("#peoplegroup").val()=="学生")
    						{
    							return "5b88e7a5dc8b5a1a84a96367";
    						}
    						
  						}
					},
       
					before: function(){
               			 console.log('接口地址：'+ this.url, this.item, {tips: 1});
            		},
					done: function(res) {
						if(res.code == 0){
							 console.log("上传成功");
						    layer.msg('人员导入成功请刷新后查看！');
						}
				        else{
				        	layer.msg(res.msg);
				        }
					    					    
											    
					},
					error: function() {
						
						layer.msg('请联系管理员');
					}
				});
			});
			


	var name=$('#groupname').val();
		 					$.ajax({
		 						type: "put",
		 						url: ip + "/questionnaire/surveyGroup/addGroup" ,
		 						data: JSON.stringify({
		 							"surveyGroupId":id,
  									"group":name
  								}),
		 						async: true,
		 						dataType: "json",
		 						contentType: "application/json",
		 						success: function(res) {
		 							if(res.code==-1){
		 								layer.msg(res.msg);
		 							}
		 							if(res.code==0){
			 							redata(id);
										layer.close(index);
									}
								},
		 						Error: function() {
		 							alert("服务器出错");
		 						}
		 					})